package website.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import website.advice.BaseResponse;
import website.domain.Classify;
import website.domain.Link;
import website.domain.Photo;
import website.domain.ResModel;
import website.service.LinkService;
import website.service.PhotoService;

import java.util.List;

@Api("照片控制类")
@BaseResponse
@RestController
@RequestMapping("/api/photo")
public class PhotoController {

    @Autowired
    private PhotoService photoService;


    @ApiOperation("查询照片")
    @GetMapping
    public ResModel<List<Photo>> list(){
        return photoService.getList();
    }

    @ApiOperation("分页查询相册")
    @GetMapping("/{current}/{size}")
    public ResModel<IPage<Photo>> getByPage(@PathVariable Integer current, @PathVariable Integer size){
        return photoService.getByPage(current,size);
    }

    @ApiOperation("分页查询自己相册")
    @GetMapping("/user/{current}/{size}/{uid}")
    public ResModel<IPage<Photo>> listByUidPhotoList(@PathVariable Integer current, @PathVariable Integer size,@PathVariable Integer uid){
        return photoService.listByUidPhotoList(current,size,uid);
    }

    @ApiOperation("删除照片")
    @DeleteMapping("/{id}")
    public ResModel delPhoto(@PathVariable Integer id){
        return photoService.delPhoto(id);
    }

    @ApiOperation("添加照片")
    @PostMapping(path = "",produces = "application/json")
    public ResModel addPhoto(@RequestBody Photo photo){
        return photoService.addPhoto(photo);
    }
}
